package creational;

public class FactoryMethod {
    public static void main(String[] args) {
        Father sona = Father.chooseSon("A");
        Father sonb = Father.chooseSon("B");

        TPhone pa = sona.getPhone();
        TPhone pb = sonb.getPhone();
    }
}
class TPhone{}
class MeiTu extends TPhone{}
class HuaWei extends TPhone{}

abstract class Father{
    public static Father chooseSon(String n){
        switch (n){
            case "A": return new Son1();
            case "B": return new Son2();
            default: return null;
        }
    }
    public abstract TPhone getPhone();
}
class Son1 extends Father{
    public void showA(){}
    public TPhone getPhone(){return new MeiTu();}
}
class Son2 extends Father{
    public TPhone getPhone(){return new HuaWei();}
}
